package 字符流;

import org.junit.Test;

import java.io.File;
import java.util.Date;

public class File类常用方法 {
    public static void main(String[] args) {
        //以文件路径创建两个对象
        File f1 = new File("hello.txt");
        File f2 = new File("D:\\he.txt");
        System.out.println("----------------------------");

        System.out.println(f1.getAbsoluteFile());
        System.out.println(new Date(f1.lastModified()));
        System.out.println("----------------------------");


        File f3=new File("D:\\私人工作空间\\JavaProjects\\Java基础练习\\src");
        String [] str= f3.list();
        for (String arg : str) {
            System.out.println(arg);
        }
        System.out.println("----------------------------");

        File [] frr=f3.listFiles();
        for (File file : frr) {
            System.out.println(file);
        }
        System.out.println("----------------------------");


    }
    @Test
    //测试renameTo()方法
    public void test4(){
        File f1=new File("hello.txt");
        File f2=new File("D:\\io\\hi.txt");
        boolean v=f1.renameTo(f2);
        System.out.println(v);

    }

}
